﻿/******************************************************************
 *Company: http://www.xiaomutech.com/
 *fileName : qaistrategy.cpp --- QAiStrategy
 *Auth       : yhni (QQ:393320854)
 *Create    : 2022/2/10
 *Description   :
 *Histroy:
 *<Auth>    <Date>        <Ver>        <Content>
 *         2022/2/10
 *******************************************************************/
#include "qaistrategy.h"

#include <QDebug>

QAiStrategy::QAiStrategy(CardList _cards, QObject *parent) : QObject(parent)
{
    m_cards = _cards;
}


CardList QAiStrategy::findCardsByCount(int count)
{
    CardList cardsArray;
    if (count < 1 || count > 4) return cardsArray;

    for (CardPoint point = Card_3; point < Card_End; point = CardPoint(point + 1))
    {
    }

    return cardsArray;
}

CardList QAiStrategy::playBeatHand(QCardHand hand)
{
    CardList _playCards;
    // 先固定住最优顺子，从余下牌中打出
    CardList left = m_cards;
    if (hand.getType() == Hand_Single)	// 如果压单牌，尽量从单张牌中挑
    {
        qDebug() << "如果压单牌，尽量从单张牌中挑";
        qDebug() << hand.getBasePoint();
        foreach(QCard *_card, left) {
            if (_card->type().point > hand.getBasePoint()) {
                _card->setSelected(true);
                _playCards.push_back(_card);
                break;
            }
        }
    }
    else if (hand.getType() == Hand_Pair)	// 如果压双牌，尽量从双牌中挑
    {

    }

    else	// 余下牌没法打时，只好从顺子中挑牌
    {

    }

    // 对家剩牌小于3张，有炸则炸
    return _playCards;
}

bool QAiStrategy::whetherToBeat(const CardList &myCards)
{
    if (myCards.isEmpty()) return true;


    // punch的是同家
    {

    }
    // punch的是对家
    {

    }

    return true;
}
